package com.server.llh.llhserverwork.utils;



import com.server.llh.llhserverwork.bean.SerInitProPackage;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

/**
 * Created by ZTF on 2017/3/21.
 * 购物车提交请求
 */

public class ShopUploadParamJson {
    /**
     * 服务提交购物车请求数据封装
     * @param listData
     * @return
     */
    public static String  reqServerParamJson(List<SerInitProPackage> listData){
        SerInitProPackage serverData = new SerInitProPackage();

        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = null;
        for (int i = 0; i < listData.size(); i++) {
            serverData = listData.get(i);
            jsonObject = new JSONObject();
            try {
                jsonObject.put("packageId", serverData.getPackId());
                jsonObject.put("packageName", serverData.getPackName());
                jsonObject.put("orgName", serverData.getOrgName());
                jsonObject.put("orgTypeId", serverData.getOrgTypeId());
                jsonObject.put("serviceCateId", serverData.getServiceCateId());
                jsonObject.put("isPro", serverData.getIsPro());
                jsonObject.put("pictureUrl", serverData.getPictureUrl());
                jsonObject.put("pictureName", serverData.getPictureName());
                jsonObject.put("reamark", serverData.getReamark());
                jsonObject.put("serNum", serverData.getBuyNum());
                jsonObject.put("price", serverData.getPrice());
                jsonObject.put("amount", serverData.getAmount());
//				jsonObject.put("supplierName", supplierName);
//				jsonObject.put("supplierId", supplierId);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            jsonArray.put(jsonObject);
        }

        String json = jsonArray.toString();
        return  json;
    }
}
